(function(vc) {


	vc.extends({
		data: {
			printInfo: {
				name: '',
				xcName:'',
				sgdw:'自装',
				floorNo: '',
				unitNo: '',
				roomNo: '',
				weiZhi: '',
				roomId: '',
				link: '',
				startDate: '',
				endDate: '',
				date: ''
			},
			printFlag: '0'
		},
		_initMethod: function() {
			//vc.component._initPrintPurchaseApplyDateInfo();

			$that.printInfo.name = vc.getParam('name');
			$that.printInfo.xcName = vc.getParam('name');
			$that.printInfo.floorNo = vc.getParam('floorNo');
			$that.printInfo.unitNo = vc.getParam('unitNo');
			$that.printInfo.roomNo = vc.getParam('roomNo');
			$that.printInfo.roomId = vc.getParam('roomId');
			$that.printInfo.link = vc.getParam('link');
			$that.printInfo.date = $that._getDate();
			$that.printInfo.startDate = $that._dateFmt(new Date);
			
			var edate = new Date();
			edate.setMonth(edate.getMonth() + 3);
			$that.printInfo.endDate = $that._dateFmt(edate);
			
			$that.printInfo.weiZhi = $that._numberToChinese(vc.getParam('floorNo')) + " 号楼" 
				+ $that._numberToChinese(vc.getParam('unitNo')) + " 单元"
				+ vc.getParam('roomNo') + "室";

			$that._loadReceipt();
		},
		_initEvent: function() {


		},
		methods: {
			_initPayFee: function() {

			},
			_dateFmt: function(dateObj) {
				var year = dateObj.getFullYear();
				var month = dateObj.getMonth() + 1; // 月份从0开始，需要加1
				var day = dateObj.getDate();
				
				return year + '年' + month + '月' + day + '日';
			},
			_getDate: function(){
				var dateObj = new Date();
				var year = dateObj.getFullYear();
				var month = dateObj.getMonth() + 1; // 月份从0开始，需要加1
				var day = dateObj.getDate();
				
				var ys = year.toString().split('');
				
				var ycn = '';
				for (i = 0; i< ys.length ; i++) {
					ycn += $that._numberToChinese(ys[i])
				}
				
				return ycn + '年' + $that._numberToChinese(month) + '月' + $that._numberToChinese(day) + '日';
			},
			_getZxzInfo: function() {
				// var param = {
				//     params: {
				//         roomId: $that.printInfo.roomId,
				//         communityId: vc.getCurrentCommunity().communityId
				//     }
				// };
				
				// //发送get请求
				// vc.http.apiGet('/feeReceipt/queryFeeReceipt',
				//     param,
				//     function(json, res) {
				//         var _feeReceiptManageInfo = JSON.parse(json);
				//         let _feeReceipt = _feeReceiptManageInfo.data;
				//         let _amount = 0;
				//         _feeReceipt.forEach(item => {
				//             _amount += parseFloat(item.amount)
				//         });
				
				//     },
				//     function(errInfo, error) {
				//         console.log('请求失败处理');
				//     }
				// );
			},
			_loadReceipt: function() {

				// var param = {
				//     params: {
				//         page: 1,
				//         row: 30,
				//         receiptId: $that.printPayFeeInfo.receiptId,
				//         receiptIds: $that.printPayFeeInfo.receiptIds,
				//         detailIds: $that.printPayFeeInfo.detailIds,
				//         communityId: vc.getCurrentCommunity().communityId
				//     }
				// };

				// //发送get请求
				// vc.http.apiGet('/feeReceipt/queryFeeReceipt',
				//     param,
				//     function(json, res) {
				//         var _feeReceiptManageInfo = JSON.parse(json);
				//         let _feeReceipt = _feeReceiptManageInfo.data;
				//         let _amount = 0;
				//         _feeReceipt.forEach(item => {
				//             _amount += parseFloat(item.amount)
				//         });

				//         $that.printPayFeeInfo.amount = _amount.toFixed(2);
				//         $that.printPayFeeInfo.roomName = _feeReceipt[0].objName;
				//         $that.printPayFeeInfo.feeTime = _feeReceipt[0].createTime;
				//         $that.printPayFeeInfo.payObjName = _feeReceipt[0].payObjName;
				//         $that.printPayFeeInfo.feeReceipt = _feeReceipt;

				//         $that._loadReceiptDetail();

				//     },
				//     function(errInfo, error) {
				//         console.log('请求失败处理');
				//     }
				// );
			},
			
			_numberToChinese: function(num){
				const chineseNumbers = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九',
				'十','十一','十二','十三','十四','十五','十六','十七','十八','十九',
				'二十','二十一','二十二','二十三','二十四','二十五','二十六','二十七','二十八','二十九',
				'三十','三十一'];
				return chineseNumbers[num];
			},
			
			_printCz: function() {
				$that.printInfo.xcName = vc.getParam('name');
				$that.printInfo.sgdw = '自装';
				$that.printInfo.link = vc.getParam('link');
				
			},

			_printPurchaseApplyDiv: function() {

				$that.printFlag = '1';
				console.log('console.log($that.printFlag);', $that.printFlag);
				document.getElementById("print-btn").style.display = "none"; //隐藏

				window.print();
				//$that.printFlag = false;
				window.opener = null;
				window.close();
			},
			_closePage: function() {
				window.opener = null;
				window.close();
			}
		}
	});

})(window.vc);